<<<<<<< HEAD
/*
import java.util.Arrays;

public class Practice {

    //为什么不能是public void transform(int[] array)
    */
/*public static void transform(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = array[i]*2;
        }
    }

//main方法为静态方法，静态方法只可以条用静态方法
    public static void main(String[] args) {
        int[] array = {1,2,3};
        transform(array);
        for (int x:array) {
            System.out.print(x+" ");
        }
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6};
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            if (left < right && array[left] % 2 != 0) {
                left++;
            }
            if (left < right && array[right] % 2 == 0) {
                right--;
            }

            if (left < right) {
                int tmp = array[left];
                array[left] = array[right];
                array[right] = tmp;
            }
        }


        for (int x : array) {
            System.out.print(x + " ");
        }
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {2, 11, 7, 15};
        int[] result = new int[2];
        int tmp = 9;
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] + array[j] == 9) {
                    result[0]=i;
                    result[1]=j;
                    break;
                }
            }
            if (result[1] != 0) {
                break;
            }
        }


        for (int x : result) {
            System.out.print(x + " ");
        }
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {4, 1, 2, 1, 2};
        int max = Integer.MIN_VALUE;//想让max足够小，然后在array数组中寻找最大的数，如果max初始为最大数，
        // 那么就因为数太大，导致无法在数组中的数进行交换
        int min = Integer.MAX_VALUE;//min跟max定义的原理一样
        for (int x : array) {
            if (x > max) max = x;
            if (x < min) min = x;
        }
        int range = max - min + 1;
        int[] count = new int[range];

        for (int x : array) {
            int index = x - min;
            count[index]++;
        }

        for (int x : array) {
            int index = x - min;
            if (count[index] == 1) {
                System.out.println(x);
                return;
            }
        }



        *//*
*/
/*for (int x : result) {
            System.out.print(x + " ");
        }*//*
*/
/*
    }*//*


    */
/*public static void main(String[] args) {
        int[] array = {2,2,1,1,1,2,2};
        int max = Integer.MIN_VALUE;//想让max足够小，然后在array数组中寻找最大的数，如果max初始为最大数，
        // 那么就因为数太大，导致无法在数组中的数进行交换
        int min = Integer.MAX_VALUE;//min跟max定义的原理一样
        for (int x : array) {
            if (x > max) max = x;
            if (x < min) min = x;
        }
        int range = max - min + 1;
        int[] count = new int[range];

        for (int x : array) {
            int index = x - min;
            count[index]++;
        }

        for (int x : array) {
            int index = x - min;
            if (count[index] == 1) {
                System.out.println(x);
                return;
            }
        }

        for (int i = 0; i < count.length-1; i++) {
            if (count[i]<count[i+1]){
                System.out.println(i);
                break;
            }
        }



        *//*
*/
/*for (int x : result) {
            System.out.print(x + " ");
        }*//*
*/
/*
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {2,2,1,-5,-5,2,2,1};
        int max = Integer.MIN_VALUE;//想让max足够小，然后在array数组中寻找最大的数，如果max初始为最大数，
        // 那么就因为数太大，导致无法在数组中的数进行交换
        int min = Integer.MAX_VALUE;//min跟max定义的原理一样
        for (int x : array) {
            if (x > max) max = x;
            if (x < min) min = x;
        }
        int range = max - min + 1;
        int[] count = new int[range];

        for (int i = 0; i < array.length; i++) {
            int index = array[i]-min;
            count[index]++;
        }
        int tmp=0;
        int fun=0;
        for (int x:array) {
            int index= x-min;
            if (count[index]>tmp){
                tmp = count[index];
                fun=x;
            }
        }

        System.out.println(fun);
*//*



        */
/*for (int x : result) {
            System.out.print(x + " ");
        }*//*

    //}

    */
/*public static void main(String[] args) {
        int[] array = {1, 2, 34, 3, 4, 5, 7, 23, 12};
        boolean bool = false;
        int tmp = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 != 0) {
                tmp++;
                if (tmp == 3) {
                    bool = true;
                    System.out.println(true);
                    return;
                }
            } else {
                tmp = 0;
            }

        }
        System.out.println(bool);
    }*//*


    */
/*public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int target = 2;
        int left = 0;
        boolean bool = false;
        int right = array.length - 1;
        while (left <= right) {
            //int mid = left + (right - left) / 2;
            int mid = left + (right - left) / 2;
            if (array[mid] == target) {
                System.out.println(true);
                return;
            } else if (array[mid] < target) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        System.out.println(bool);
    }*//*

    */
/*public class BubbleSort {

    public static void main(String[] args) {
        int[] array = {5, 3, 8, 4, 2};
        System.out.println("排序前: " + Arrays.toString(array));
        bubbleSort(array);
        System.out.println("排序后: " + Arrays.toString(array));
    }
}*//*

*/
/**
 * 冒泡排序（升序）
 *
 * @param arr 待排序的数组
 *//*

   */
/* public static void bubbleSort(int[] arr) {
        // 1. 外层循环控制遍历次数（n 个元素需要 n-1 轮遍历）
        for (int i = 0; i < arr.length - 1; i++) {
            // 优化标记：若某次遍历未发生交换，说明已有序，提前结束
            boolean swapped = false;

            // 2. 内层循环处理相邻元素比较和交换
            // 每轮遍历后，最大的元素会"沉"到末尾，因此内层循环范围逐渐缩小
            for (int j = 0; j < arr.length - 1 - i; j++) {
                // 如果前一个元素比后一个元素大，则交换它们
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                    swapped = true; // 标记发生交换
                }
            }

            // 3. 若本轮未发生交换，说明数组已完全有序，提前终止排序
            if (!swapped) {
                break;
            }
        }
    }
    *//*

*/
/*
class Solution {
    public int countSegments(String s) {
        String[] str = s.split(" ");
        int i = 0;
        for (String x : str) {
            // String tmp =s.split(" ");
            if (x != null) {
                i++;
            }
        }
        return i;
    }
*//*

    */
/*class Solution {
        public int countSegments(String s) {
            // Trim the string to remove leading and trailing spaces
            s = s.trim();
            // If the string is empty after trimming, return 0
            if (s.isEmpty()) {
                return 0;
            }
            // Split the string by spaces using regex "\\s+"
            String[] words = s.split("\\s+");
            // Return the number of words
            return words.length;
        }*//*


*/
/*class Solution {
    public int countSegments(String s) {
         = s.trim();
        if (s.isEmpty()){
            return 0;
        }

        String[] tmp  = s.split("\\s+");
        return tmp.length;


}
*/
=======
/*
import java.util.Arrays;

public class Practice {

    //为什么不能是public void transform(int[] array)
    */
/*public static void transform(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = array[i]*2;
        }
    }

//main方法为静态方法，静态方法只可以条用静态方法
    public static void main(String[] args) {
        int[] array = {1,2,3};
        transform(array);
        for (int x:array) {
            System.out.print(x+" ");
        }
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6};
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            if (left < right && array[left] % 2 != 0) {
                left++;
            }
            if (left < right && array[right] % 2 == 0) {
                right--;
            }

            if (left < right) {
                int tmp = array[left];
                array[left] = array[right];
                array[right] = tmp;
            }
        }


        for (int x : array) {
            System.out.print(x + " ");
        }
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {2, 11, 7, 15};
        int[] result = new int[2];
        int tmp = 9;
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] + array[j] == 9) {
                    result[0]=i;
                    result[1]=j;
                    break;
                }
            }
            if (result[1] != 0) {
                break;
            }
        }


        for (int x : result) {
            System.out.print(x + " ");
        }
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {4, 1, 2, 1, 2};
        int max = Integer.MIN_VALUE;//想让max足够小，然后在array数组中寻找最大的数，如果max初始为最大数，
        // 那么就因为数太大，导致无法在数组中的数进行交换
        int min = Integer.MAX_VALUE;//min跟max定义的原理一样
        for (int x : array) {
            if (x > max) max = x;
            if (x < min) min = x;
        }
        int range = max - min + 1;
        int[] count = new int[range];

        for (int x : array) {
            int index = x - min;
            count[index]++;
        }

        for (int x : array) {
            int index = x - min;
            if (count[index] == 1) {
                System.out.println(x);
                return;
            }
        }



        *//*
*/
/*for (int x : result) {
            System.out.print(x + " ");
        }*//*
*/
/*
    }*//*


    */
/*public static void main(String[] args) {
        int[] array = {2,2,1,1,1,2,2};
        int max = Integer.MIN_VALUE;//想让max足够小，然后在array数组中寻找最大的数，如果max初始为最大数，
        // 那么就因为数太大，导致无法在数组中的数进行交换
        int min = Integer.MAX_VALUE;//min跟max定义的原理一样
        for (int x : array) {
            if (x > max) max = x;
            if (x < min) min = x;
        }
        int range = max - min + 1;
        int[] count = new int[range];

        for (int x : array) {
            int index = x - min;
            count[index]++;
        }

        for (int x : array) {
            int index = x - min;
            if (count[index] == 1) {
                System.out.println(x);
                return;
            }
        }

        for (int i = 0; i < count.length-1; i++) {
            if (count[i]<count[i+1]){
                System.out.println(i);
                break;
            }
        }



        *//*
*/
/*for (int x : result) {
            System.out.print(x + " ");
        }*//*
*/
/*
    }*//*



    */
/*public static void main(String[] args) {
        int[] array = {2,2,1,-5,-5,2,2,1};
        int max = Integer.MIN_VALUE;//想让max足够小，然后在array数组中寻找最大的数，如果max初始为最大数，
        // 那么就因为数太大，导致无法在数组中的数进行交换
        int min = Integer.MAX_VALUE;//min跟max定义的原理一样
        for (int x : array) {
            if (x > max) max = x;
            if (x < min) min = x;
        }
        int range = max - min + 1;
        int[] count = new int[range];

        for (int i = 0; i < array.length; i++) {
            int index = array[i]-min;
            count[index]++;
        }
        int tmp=0;
        int fun=0;
        for (int x:array) {
            int index= x-min;
            if (count[index]>tmp){
                tmp = count[index];
                fun=x;
            }
        }

        System.out.println(fun);
*//*



        */
/*for (int x : result) {
            System.out.print(x + " ");
        }*//*

    //}

    */
/*public static void main(String[] args) {
        int[] array = {1, 2, 34, 3, 4, 5, 7, 23, 12};
        boolean bool = false;
        int tmp = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 != 0) {
                tmp++;
                if (tmp == 3) {
                    bool = true;
                    System.out.println(true);
                    return;
                }
            } else {
                tmp = 0;
            }

        }
        System.out.println(bool);
    }*//*


    */
/*public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int target = 2;
        int left = 0;
        boolean bool = false;
        int right = array.length - 1;
        while (left <= right) {
            //int mid = left + (right - left) / 2;
            int mid = left + (right - left) / 2;
            if (array[mid] == target) {
                System.out.println(true);
                return;
            } else if (array[mid] < target) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        System.out.println(bool);
    }*//*

    */
/*public class BubbleSort {

    public static void main(String[] args) {
        int[] array = {5, 3, 8, 4, 2};
        System.out.println("排序前: " + Arrays.toString(array));
        bubbleSort(array);
        System.out.println("排序后: " + Arrays.toString(array));
    }
}*//*

*/
/**
 * 冒泡排序（升序）
 *
 * @param arr 待排序的数组
 *//*

   */
/* public static void bubbleSort(int[] arr) {
        // 1. 外层循环控制遍历次数（n 个元素需要 n-1 轮遍历）
        for (int i = 0; i < arr.length - 1; i++) {
            // 优化标记：若某次遍历未发生交换，说明已有序，提前结束
            boolean swapped = false;

            // 2. 内层循环处理相邻元素比较和交换
            // 每轮遍历后，最大的元素会"沉"到末尾，因此内层循环范围逐渐缩小
            for (int j = 0; j < arr.length - 1 - i; j++) {
                // 如果前一个元素比后一个元素大，则交换它们
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                    swapped = true; // 标记发生交换
                }
            }

            // 3. 若本轮未发生交换，说明数组已完全有序，提前终止排序
            if (!swapped) {
                break;
            }
        }
    }
    *//*

*/
/*
class Solution {
    public int countSegments(String s) {
        String[] str = s.split(" ");
        int i = 0;
        for (String x : str) {
            // String tmp =s.split(" ");
            if (x != null) {
                i++;
            }
        }
        return i;
    }
*//*

    */
/*class Solution {
        public int countSegments(String s) {
            // Trim the string to remove leading and trailing spaces
            s = s.trim();
            // If the string is empty after trimming, return 0
            if (s.isEmpty()) {
                return 0;
            }
            // Split the string by spaces using regex "\\s+"
            String[] words = s.split("\\s+");
            // Return the number of words
            return words.length;
        }*//*


*/
/*class Solution {
    public int countSegments(String s) {
         = s.trim();
        if (s.isEmpty()){
            return 0;
        }

        String[] tmp  = s.split("\\s+");
        return tmp.length;


}
*/
>>>>>>> 910c449b2d9609f5488fada51d1fca89c0904e69
